<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>计算圆的周长面积</title>
	</head>
	<body>
		<p>请输入圆的半径</p>
		<input id="r" type="text">
		<br />
		<br />
		<br />
		<input id="butn1" type="button" value="计算圆的周长" onclick="calculate()"/>
		<input id="butn2" type="button" value="计算圆的面积" onclick="calculate1()"/>
		<p id="print"></p>
		<p id="print1"></p>
		
		<!--shift+> 结尾标签快捷家-->
		<script>
			function calculate(){
				var num=document.getElementById("r");
				var print=document.getElementById("print");
				var result=3.14*num.value*num.value;
				 if(isNaN(num.value)){
				 	alert("请输入数字");
				 }
				 else if(num.value==""){
				 	alert("半径不能为空");
				 }
				 else{
				 print.innerHTML="圆的周长="+result;
				 
			
				 }
				
			}
			function calculate1(){
				var num=document.getElementById("r");
				var print1=document.getElementById("print1");
				var result=2*3.14*num.value*num.value;
				 if(isNaN(num.value)){
				 	alert("请输入数字");
				 }
				 else if(num.value==""){
				 	alert("半径不能为空");
				 }
				 else{
				 print1.innerHTML="圆的面积="+result;
				 
			
				 }
				
			}
		
			
		</script>
	</body>
</html>
